using System;
using System.Collections;
using System.Collections.Generic;

namespace SmellyCode {

	public class DuplicationLover {

		private IList myList;

		public DuplicationLover() {
			myList = new ArrayList();
			myList.Add("Foo");
			myList.Add("Bar");
			myList.Add("Baz");
		}

		public void MakeStuff() {
			foreach (string value in myList) {
				Console.WriteLine(value);
				If1();
			}
		}

		public void MakeMoreStuff() {
			foreach (string value in myList) {
				Console.WriteLine(value);
				Console.WriteLine("kaboom");
			}
		}

		public void If1() {
			if (myList == null) {
				Console.WriteLine("list is null");
				int p = 9;
				Console.WriteLine("list is nullagain");
				Console.WriteLine("list is null"+p);
			}
		}

		public void If2() {
			if (myList == null) {
				Console.WriteLine("list is null");
				int p = 9;
			}
		}

		public void While1() {
			int i = 1;
			while (i < 2) {
				Console.WriteLine("babbla");
				i++;
			}
		}

		public void While2() {
			int i = 1;
			while (i < 2) {
				Console.WriteLine("babbla");
				i++;
			}
		}

		public void For1() {
			for (int l = 0; l < 4; l++) {
				Console.WriteLine("jawn" + l);
			}
		}

		public void For2() {
			for (int l = 0; l < 4; l++) {
				Console.WriteLine("jawn" + l);
			}
		}

	}

	public class BaseClassWithCodeDuplicated {
		protected IList list;
	}

	public class OverriderClassWithCodeDuplicated : BaseClassWithCodeDuplicated {
		public void CodeDuplicated() {
			foreach (int i in list) {
				Console.WriteLine(i);
			}
			list.Add(1);
		}
	}

	public class OtherOverriderWithCodeDuplicated : BaseClassWithCodeDuplicated {
		public void OtherMethod() {
			foreach (int i in list) {
				Console.WriteLine(i);
			}
			list.Remove(1);
		}
	}
}

